package sample.nacos.client;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@Slf4j
@EnableDiscoveryClient
@EnableSwagger2
public class App {

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(App.class,args);
        String name = context.getEnvironment().getProperty("user.name");
        String age = context.getEnvironment().getProperty("user.age");
        System.out.println("name:" + name +";age:"+age);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
